﻿using System.Windows.Forms;
using CommonLibrary.Logic;
using CommonLibrary.Models.Profiles;

namespace CommonLibrary.Extensions
{
    static class ProfileConfigExtensions
    {
        public static ActionEvent GetGenericActionForAxis(this ProfileConfigGenerator.Axis axis)
        {
            ActionEvent actionEvent = new ActionEvent();

            switch (axis)
            {
                case ProfileConfigGenerator.Axis.LeftX:
                    actionEvent.Type = TypeOfAction.ButtonAxis;
                    actionEvent.Id = "D";
                    actionEvent.OpositeId = "A";
                    break;
                case ProfileConfigGenerator.Axis.LeftY:
                    actionEvent.Type = TypeOfAction.ButtonAxis;
                    actionEvent.Id = "W";
                    actionEvent.OpositeId = "S";
                    break;
                case ProfileConfigGenerator.Axis.RightX:
                    actionEvent.Type = TypeOfAction.Axis;
                    actionEvent.DeadZone = 20;
                    actionEvent.Multiplier = 8;
                    actionEvent.Shape = ShapeOfDeadZone.Circle;
                    actionEvent.Id = "Mouse_Axis_X";
                    break;
                case ProfileConfigGenerator.Axis.RightY:
                    actionEvent.Type = TypeOfAction.Axis;
                    actionEvent.DeadZone = 20;
                    actionEvent.Multiplier = 8;
                    actionEvent.Shape = ShapeOfDeadZone.Circle;
                    actionEvent.Id = "Mouse_Axis_Y";
                    break;
            }

            return actionEvent;
        }

        public static ActionEvent GetGenericActionForButton(this ProfileConfigGenerator.Button button)
        {
            ActionEvent actionEvent = new ActionEvent();
            actionEvent.Type = TypeOfAction.Button;
            
            switch (button)
            {
                case ProfileConfigGenerator.Button.Select:
                    actionEvent.Id = Keys.Tab.ToString();
                    break;
                case ProfileConfigGenerator.Button.PS:
                    actionEvent.Id = Keys.Enter.ToString();
                    break;
                case ProfileConfigGenerator.Button.Start:
                    actionEvent.Id = Keys.C.ToString();
                    break;

                case ProfileConfigGenerator.Button.Triangle:
                    actionEvent.Id = Keys.E.ToString();
                    break;
                case ProfileConfigGenerator.Button.Square:
                    actionEvent.Id = Keys.R.ToString();
                    break;
                case ProfileConfigGenerator.Button.Cross:
                    actionEvent.Id = Keys.T.ToString();
                    break;
                case ProfileConfigGenerator.Button.Circle:
                    actionEvent.Id = Keys.Y.ToString();
                    break;

                case ProfileConfigGenerator.Button.Left:
                    actionEvent.Id = Keys.Left.ToString();
                    break;
                case ProfileConfigGenerator.Button.Right:
                    actionEvent.Id = Keys.Right.ToString();
                    break;
                case ProfileConfigGenerator.Button.Up:
                    actionEvent.Id = Keys.Up.ToString();
                    break;
                case ProfileConfigGenerator.Button.Down:
                    actionEvent.Id = Keys.Down.ToString();
                    break;

                case ProfileConfigGenerator.Button.L1:
                    actionEvent.Id = Keys.NumPad1.ToString();
                    break;
                case ProfileConfigGenerator.Button.R1:
                    actionEvent.Id = Keys.NumPad4.ToString();
                    break;
                case ProfileConfigGenerator.Button.L2:
                    actionEvent.Id = Keys.NumPad2.ToString();
                    break;
                case ProfileConfigGenerator.Button.R2:
                    actionEvent.Id = Keys.NumPad5.ToString();
                    break;
                case ProfileConfigGenerator.Button.L3:
                    actionEvent.Id = Keys.NumPad3.ToString();
                    break;
                case ProfileConfigGenerator.Button.R3:
                    actionEvent.Id = Keys.NumPad6.ToString();
                    break;
            }

            return actionEvent;
        }
    }
}
